<link href="/css/order/detail.css" rel="stylesheet" type="text/css">
<link href="/css/order/order.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
    var paginationTotal = 1;
    var paginationPageSize = 10;
    $(function() {
        initData(0);
    })
    function search() {
        initData(0);
    }
    function loadData(page, pageSize) {
        $("#LoadData").empty();
        $.ajax({
            type: "POST",
            async: false,
            dataType: "json",
            url: "/order/order/productlist/page/" + page + "/pageSize/" + pageSize,
            data:"customer_id=" + $("#customer_id").val() + "&product_id=" + $("#product_id").val(),
            success: function(json) {
                var Html = "";
                paginationTotal = json.count;
                if (json.ask == 0) {
                    list = "<div>&nbsp;<{$lang.no_data}></div>";
                } else {
                    $.each(json.result, function(key, val) {
                        var rowStyle = (key % 2 == 0) ? "divGray" : "divWhite";
                        Html += "<div class=\"" + rowStyle + "\">";
                        Html += "<div class=\"pColumn2\">" + val.product_img + "</div>";
                        Html += "<div class=\"pColumn3\">" + val.product_id + "</div>";
                        Html += "<div class=\"pColumn4\">" + val.product_title + "</div>";
                        Html += "<div class=\"pColumn5\">" + val.wp_quantity + "</div>";
                        Html += "<div class=\"pColumn6\">" + val.ws_code + "</div>";
                        Html += "<div class=\"pColumn1\"><a href=\"javascript:addPro(" + val.product_id + ");\"><{$lang.add}></a></div>";
                        Html += "</div>";
                    });
                }
                $("#LoadData").html(Html);
            }
        });
    }
    function addPro(pid) {
        if (pid == '') {
            return;
        }
        $.ajax({
            type: "post",
            async: false,
            dataType: "json",
            url: "/order/order/addproduct",
            data:{
                'product_id':pid,
                'orders_code':$("#orders_code").val()
            },
            success: function(json) {
                if (json == null) {
                    return
                }
                if (json.ask == '1') {
                    var orders_code = window.parent.document.getElementById('is_orders_code').value;
                    window.parent.detail(orders_code);//填充<{$lang.order}>资料;
                    window.parent.alertTip(json.msg);
                } else {
                    window.parent.alertTip(json.msg);
                }
            }
        });

    }

</script>
<!-- product select start -->
<style type="text/css">
    .pColumn1 {
        width: 8%;
        float: left;
        line-height: 25px;
    }

    .pColumn2 {
        width: 10%;
        float: left;
        line-height: 25px;
    }

    .pColumn3 {
        width: 12%;
        float: left;
        line-height: 25px;
    }

    .pColumn4 {
        width: 40%;
        float: left;
        line-height: 25px;
        text-align: left;
    }

    .pColumn5 {
        width: 18%;
        float: left;
        line-height: 25px;
    }

    .pColumn6 {
        width: 10%;
        float: left;
        line-height: 25px;
    }

    .pProduct_img {
        width: 25px;
        height: 25px;
        border: 0px;
    }
</style>
<div id="product_page">
    <div class="iTitle">
        <div>
            <form id="pForm" name="pForm">
                &nbsp;&nbsp;<{$lang.product}>ID<{$lang.or}><{$lang.name}>：<input id="product_id" name="product_id" type="text" size="14"/>
                <input type="hidden" id="customer_id" name="customer_id" value="<{$customer_id}>">
                <input type="hidden" id="orders_code" name="orders_code" value="<{$orders_code}>">
                <input type="button" value="<{$lang.search}>" onclick="search();" class="button"/>
            </form>
        </div>
        <div class="myClear"></div>
    </div>
    <div id="iContent" class="iContent">
        <div id="iHead" class="iHead">
            <div class="pColumn2"><{$lang.picture}></div>
            <div class="pColumn3">ID</div>
            <div class="pColumn4"><{$lang.product}></div>
            <div class="pColumn5"><{$lang.inventory}></div>
            <div class="pColumn6"><{$lang.ws_code}></div>
            <div class="pColumn1"><{$lang.pls}></div>
            <div class="myClear"></div>
        </div>
        <span id="LoadData"></span>
    </div>
    <div id="pagination" class="pagination"></div>
    <br/>

</div>
<!-- product select end -->